<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/include/jQgrid.jsp"%>

</head>
<body style="background-color: white;" class="gray-bg">
                    <div class="ibox-content">
                        <form  class="form-horizontal m-t" id="signupForm">
                        <div class="form-group">
                                <label class="col-sm-3 control-label">键值：</label>
                                <div class="col-sm-8">
                                    <input id="value" name="value"  class="form-control" type="text"  />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">字典类型：</label>
                                <div class="col-sm-8">
                                    <input id="type" name="type" value="${dictionarydata.type }" class="form-control" type="text">
                                    <span class="help-block m-b-none"><i class="glyphicon glyphicon-info-sign"></i>用于区分字典类别</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">显示值：</label>
                                <div class="col-sm-8">
                                    <input id="valueName" name="valueName"  class="form-control" type="text" aria-required="true" aria-invalid="false" class="valid">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">描述：</label>
                                <div class="col-sm-8">
                                    <input id="description" name="description"  value="${dictionarydata.description }"  class="form-control" type="text" aria-required="true" aria-invalid="false" class="valid">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">是否可编辑：</label>
                                <div class="col-sm-8">
	                                <select name="isfixed"  class="form-control" >
	                                   	<option value="0"  <c:if test="${dictionarydata.isfixed==0 }">selected</c:if> >是</option>
	                                   	<option value="1" <c:if test="${dictionarydata.isfixed==1 }"> selected=selected </c:if>>否</option>
	                                </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary" type="button" id="sub">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
	
	
	<script>
	$(function(){
	    $("#sub").click(function(){
	    if($("#value").val().length==0){
				$("#value").tips({
					side:3,
		            msg:'键值不能为空！',
		            bg:'#AE81FF',
		            time:1
		        });
				$("#value").focus();
				return;
			}
	    	if($("#type").val().length==0){
				$("#type").tips({
					side:3,
		            msg:'字典类别不能为空！',
		            bg:'#AE81FF',
		            time:1
		        });
				$("#type").focus();
				return;
			}
			if($("#description").val().length==0){
				$("#description").tips({
					side:3,
		            msg:'描述不能为空！',
		            bg:'#AE81FF',
		            time:1
		        });
				$("#description").focus();
				return;
			}
			if($("#valueName").val().length==0){
				$("#valueName").tips({
					side:3,
		            msg:'字典显示值不能为空！',
		            bg:'#AE81FF',
		            time:1
		        });
				$("#valueName").focus();
				return;
			}
			$("#signupForm").ajaxSubmit({
	        	url:'<%=contextPath %>/dictionarydata/add',
	        	type:'post',
	        	dataType:"json",
	        	success:function(data){
	        		if(data.code==200){
	        			swal({
	        			    title: data.message,
	        			    type: "success",
	        			    showCancelButton: false,
	        			    confirmButtonText: "确定",
	        			    animation:"slide-from-bottom",
	        			    closeOnConfirm: true
	        			},function(){
	        				top.Dialog.close();
	        			});
	        		}else{
	        			swal("错误", data.message, "error");
	        		}
	        	}
	      }); 
			
		});
	});
	</script>
</body>
</html>